import React from 'react';
import { history } from 'umi'
import { Radio, Tooltip, Button } from 'antd';
import classNames from 'classnames';

import AuthComponent from '@/utils/auth/AuthComponent';
import { hrOverviewRecheck, salaryRecheck, hrRecheck } from '@/services/salaryManage/salaryCalculate';
import { goToSalaryRecheckLog } from '@/pages/SalaryManage/utils/pageNavigateUtil';
import salaryStyles from '@/pages/SalaryManage/salaryManage.less';
import BaseOverviewRecheckModel from '../BaseOverviewRecheckModel';


const { getRecheckSteps, latestSalaryYearMonth } = salaryRecheck;
const {
    queryTableBodyData,
    getCheckButtons,
    passCheck,
    finalPassCheck,
    rejectCheck,
    finalRejectCheck
} = hrOverviewRecheck;

const { updateData } = hrRecheck;

const hrOverviewRecheckModel = BaseOverviewRecheckModel('hrOverviewRecheckModel', {
    latestSalaryYearMonth,
    getRecheckSteps,
    getCheckButtons,
    queryTableBodyData,
    updateData,
    passCheck,
    finalPassCheck,
    rejectCheck,
    finalRejectCheck
});

hrOverviewRecheckModel.state.actionType = 1;

hrOverviewRecheckModel.state.RecheckMenuRight = ({ searchModel }) => {
    const goDetail = () => {
        history.push({
            pathname: '/finance/salary/calculate/recheck/hrrecheck/detail'
        });
    }

    const { organizationCode } = searchModel

    return (
        <div>
            <Radio.Group className={classNames(salaryStyles.switchRadio, salaryStyles.mr8)} value="overView">
                <AuthComponent code="finance:salary:computation:check:hrcollect">
                    <Tooltip title="总览">
                        <Radio.Button value="overView">
                            <i className="icon iconfont iconzonglan" />
                        </Radio.Button>
                    </Tooltip>
                </AuthComponent>
                <AuthComponent code="finance:salary:computation:check:hrdetail">
                    <Tooltip title="详细">
                        <Radio.Button value="detail" onClick={goDetail}>
                            <i className="icon iconfont iconxiangxi" />
                        </Radio.Button>
                    </Tooltip>
                </AuthComponent>
            </Radio.Group>
            <Button onClick={() => goToSalaryRecheckLog(organizationCode)}>操作日志</Button>
        </div>
    );
}

export default hrOverviewRecheckModel;
